/*
 * Created by SharpDevelop.
 * User: fatman
 * Date: 10/27/2008
 * Time: 7:35 PM
 * 
 * To change this template use Tools | Options | Coding | Edit Standard Headers.
 */

using System;
using System.Drawing;

namespace CUALib
{
	/// <summary>
	/// Description of MenuBar.
	/// </summary>
	public class MenuBar: ConsoleControl
	{
		public MenuBar(bool consoleExists): base(consoleExists)
		{
			this.Height=1;
			this.Width=1;
		}
		
		
		
		public override void Invalidate(System.Drawing.Rectangle rect)
		{
			if (!Visible)
				return;	
			Redraw();
		}
		
		internal override void Redraw()
		{
			ConsoleColor oldForeColor = Console.ForegroundColor;
			Console.ForegroundColor = ForegroundColor;
			ConsoleColor oldBackColor = Console.BackgroundColor;
			Console.BackgroundColor = BackgroundColor;
			Point oldCursorLocation = new Point(Console.CursorLeft, Console.CursorTop);

			Rectangle ab=AbsoluteBounds;
			Console.SetCursorPosition(ab.X, ab.Y);
			string line="";
			line=line.PadRight(ab.Width,DecorationSet[BoxDrawingDecorationNames.menubarBackground]);
			Console.Write(line);
			
			Console.ForegroundColor = oldForeColor;
			Console.BackgroundColor = oldBackColor;
			Console.SetCursorPosition(oldCursorLocation.X, oldCursorLocation.Y);

			
		}
		
		
		public override System.Drawing.Point Location
		{
			get { return System.Drawing.Point.Empty; }
		}
		public override int Height
		{
			get { return 1; }
		}
		public override ConsoleControl Parent
		{
			get { return base.Parent; }
			set
			{
				base.Parent = value;
				Width=base.Parent.Width;
				
			}
		}
		

		
	}
}
